<template>
  <div>
    <slot />
    <el-button v-if="params.isShowConfirm !== false" type="primary" @click="confirm">确 定</el-button>
    <el-button v-if="params.isShowCancel !== false" @click="cancel">取 消</el-button>
  </div>
</template>

<script>
export default {
  name: 'DialogBtn',
  props: {
    params: {
      type: Object,
      default: () => {
        return {
          isShowConfirm: true, // 是否显示确认按钮
          isShowCancel: true // 是否显示取消按钮
        }
      }
    }
  },
  data: () => {
    return {}
  },
  methods: {
    cancel() {
      const parentVue = this.$parent.$parent
      if (parentVue.cancel) {
        parentVue.cancel()
      } else if (parentVue.params.cancel) {
        parentVue.params.cancel()
      } else {
        parentVue.params.visible = false
      }
    },
    confirm() {
      const parentVue = this.$parent.$parent
      if (parentVue.confirm) {
        parentVue.confirm()
      }
    }
  }
}
</script>

<style>
</style>
